package ch.app.service.impl;
import java.io.Serializable;
import java.util.Date;

import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Service;
  
@Service(value = "redisService")
public class RedisServiceImpl {  
      
    @Autowired  
    private RedisTemplate redisTemplate;    
      
   /* public boolean set(String key, String obj) {
    	redisTemplate.opsForHash().put("1234", new Date(), "james");
    	
		return true;
    }*/
    
    public boolean set(final String key, Object value) {
        boolean result = false;
        try {
        ValueOperations<Serializable, Object> operations = redisTemplate.opsForValue();
        operations.set(key, value);
        result = true;
        } catch (Exception e) {
        e.printStackTrace();
        }
        return result;
    }
}  